//
//  HWWatchView.m
//  HWanGame
//
//  Created by 陈道斌 on 2021/7/22.
//  Copyright © 2021 Chendaobin. All rights reserved.
//

#import "HWWatchView.h"

@interface HWWatchView()

@property(strong,nonatomic) UIView *grayView;
@property(strong,nonatomic) UIView *baiseView;
@property(strong,nonatomic) UILabel *chakanYuanLabel;
@property(strong,nonatomic) UILabel *neirongLabel;
//@property(strong,nonatomic) UIImageView *tupianiamgeView;
//@property(strong,nonatomic) UIImageView *quxiaoicoIamgeView;

@end

@implementation HWWatchView



- (instancetype)initWithFrame:(CGRect)frame  {
    
    if (self  = [super initWithFrame:frame]) {
        // 添加灰色背景
        [self addgrayView];
        
        [self setupUI];
        
        
    }
    return  self;
    
}


//  设置UI
- (void)setupUI {
    
//    // 游戏的图片
    self.baiseView = [[UIView alloc] initWithFrame:CGRectMake(30, (kScreenH-150)/2, kScreenW-60, 150)];
    self.baiseView.userInteractionEnabled = YES;
 //   self.tupianiamgeView.image = [UIImage imageNamed:@"tankuanjimianico"];
    self.baiseView.backgroundColor = [UIColor whiteColor];
    self.baiseView.layer.cornerRadius = 5;
    self.baiseView.layer.masksToBounds = YES;
    [self addSubview:self.baiseView];
    
    
    self.chakanYuanLabel  = [[UILabel alloc]initWithFrame:CGRectMake(0,0,kScreenW-60, 30)];
   //  self.huishouxuzhiLabel.backgroundColor = RGB(255, 217, 161);
//    self.huishouxuzhiLabel.layer.cornerRadius = 32;
//    self.huishouxuzhiLabel.layer.masksToBounds = YES;
    self.chakanYuanLabel.textColor = RGB(51 , 51, 51);
    self.chakanYuanLabel.textAlignment = NSTextAlignmentCenter;
    self.chakanYuanLabel.font = [UIFont systemFontOfSize:15];
    self.chakanYuanLabel.text = @"查看原因";
    [self.baiseView addSubview:self.chakanYuanLabel];
    
    
    
    self.neirongLabel  = [[UILabel alloc]initWithFrame:CGRectMake(10, self.chakanYuanLabel.bottom,kScreenW-60-20, 60)];
   //  self.huishouxuzhiLabel.backgroundColor = RGB(255, 217, 161);
//    self.huishouxuzhiLabel.layer.cornerRadius = 32;
//    self.huishouxuzhiLabel.layer.masksToBounds = YES;
    self.neirongLabel.textColor = RGB(51 , 51, 51);
    self.neirongLabel.textAlignment = NSTextAlignmentLeft;
    self.neirongLabel.font = [UIFont systemFontOfSize:13];
    self.neirongLabel.text = @"";
    [self.baiseView addSubview:self.neirongLabel];
    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake((kScreenW-60-120)/2,150-45, 120, 35);
    // button.backgroundColor = [UIColor redColor];
  //   [button setImage:[UIImage imageNamed:@"details_back"] forState:UIControlStateNormal];
    [button  setTitle:@"关闭" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonTap) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = RGB(79, 134, 255);
    button.layer.cornerRadius = 5;
    button.layer.masksToBounds= YES;
    [self.baiseView addSubview:button];

    
    
    
    
    
    
    


    

    
    
    
    
    
    
 
    
}


- (void)buttonTap {
    
    
    
    [self removeFromSuperview];
    
    
    
}





//取消按钮
- (void)quxiaoicoIamgeViewTap {
    
    [self removeFromSuperview];
    
    
}







// 添加灰色View
-(void)addgrayView {
    
    self.grayView = [[UIView alloc]init];
    self.grayView.frame  = CGRectMake(0,0, kScreenW, kScreenH);
    
    self.grayView.backgroundColor =  RGB(0, 0, 0);
    self.grayView.alpha = 0.7;
    [self addSubview:self.grayView];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapView:)];
    //  tap.delegate = self;
    [self.grayView addGestureRecognizer:tap];
    
    
    
    
}



- (void)tapView:(UITapGestureRecognizer *)touch {
    
     [touch.view.superview removeFromSuperview];
    //   [[NSNotificationCenter defaultCenter] postNotificationName:@"notifyName1" object:nil];
    
    
}

- (void)shuxingview {
    
    self.neirongLabel.text =self.leirongStr;
    
    
}



@end
